<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    h1 {
      width: 500px;
      height: 500px;
      margin: 0 auto;
      font-size: 100px;
      text-align: center;
      border: 1px solid #000;
    }

    /* 只在打印机或者打印预览的才应用样式 */
    @media print {
      h1 {
        color: red;
        font-size: 20px;
      }
    }

    /*  屏幕 */
    @media screen {
      h1 {
        color: blue;
        font-size: 30px;
      }
    }

    /* 所有设备 */
    @media all {
      h1 {
        color: green;
        font-size: 40px;
      }
    }
  </style>
</head>

<body>
  <h1>媒体查询</h1>
</body>

</html>